﻿@using CodeCamp.Models.Schedule
@using CodeCamp.Models.Shared
@using CodeCamp.Infrastructure.Extensions
@model ScheduleRoomViewModel
@{
    ViewBag.Title = "";
    string headline;
    if ((@Model != null) && (@Model.EventDisplayName != null))
    {
        ViewBag.Title = string.Format("{0} | Schedule for {1}, {2}", Model.EventDisplayName, Model.Building, Model.Room);
        headline = string.Format("{0} Schedule for {1}, {2}", Model.EventDisplayName, Model.Building, Model.Room);
    }
    else
    {
        ViewBag.Title = "Code Camp | Schedule for Room";
        headline = "Code Camp Schedule by Room";
    }
}

@if (Model.ScheduleIsPublic)
{
<h2>@headline</h2>
}
else
{
<h2>@headline - NOT YET PUBLIC</h2>
}
@if (!string.IsNullOrWhiteSpace(Model.RoomInfo))
{
    <h3>@Model.RoomInfo</h3>
}

<p>
    View the @Html.ActionLink("Agenda", "Agenda", new { eventName = Model.EventShortName }) to see @Model.EventDisplayName at a glance.
    View the @Html.ActionLink("Session Schedule", "Index", new { eventName = Model.EventShortName }) to see the schedule arranged chronologically.
    View the @Html.ActionLink("Session Schedule by Room", "Rooms", new { eventName = Model.EventShortName }) to see the schedule for all rooms.
</p>
<p>
    Details are subject to change. But you already knew that.
</p>

<h3>@Model.EventStartDate.ToLongDateString()</h3>

@if (Model.ScheduleIsPublic || Model.ScheduleInsider || Model.ScheduleVisibleForPresenter)
{
  <table class="scheduleByRoom">
    <tr class="horizontalLayout">
      <td class="col1"></td>
      <td class="col2"></td>
      <td class="col3"></td>
      <td class="col4"></td>
    </tr>
    <tr class="roomRow">
        <td colspan="4">@string.Format("{0}, {1}", Model.Building, Model.Room)</td>
    </tr>
      @foreach (var session in Model.Sessions)
      {
          <tr class="sessionRow">
            <td></td>
            <td class="time">@session.StartTime.ToShortTimeString() &ndash;
                        @session.EndTime.ToShortTimeString()</td>
            <td class="session">@Html.ActionLink(session.Title, "Details", "Sessions", new { eventName = Model.EventShortName, id = session.SessionId }, null)</td>
            <td class="presenters">
            @{
                var first = true;
                foreach(var presenter in session.Presenters)
                {
                    if (!first) { <text>, </text> }
                    else { first = false; }
                    @Html.ActionLink(presenter.Name, "Details", "Presenters", new { eventName = Model.EventShortName, id = presenter.PresenterId}, null)
                }
            }
            </td>
          </tr>
      }
  </table>
}

@section sidebar {
    @Html.Partial("SidebarCommonPartial")
}
